<?php
namespace app\adminmall\controller;
use app\common\controller\AdminBaseController;
use think\Db;

/**
 * 会员消费统计
 */
class ExpenseController extends AdminBaseController {
	
	public function index(){
		$map = [];
		if(request()->isPost()){
		 	$param = input('post.');
			//用户名称
			if($param['nick_name']){
				$map['b.nick_name'] = ['like', '%'.$param['nick_name'].'%'];
			}
			//手机号码
			if($param['mobile']){
				$map['b.mobile'] = ['like', '%'.$param['mobile'].'%'];
			}		 				
	 	}
		$list = Db::name('mall_consmember')
		->alias('a')
		->join('member b','b.id = a.u_id','LEFT')
		->field('a.u_id,count(a.id) count,sum(a.score) score,b.nick_name,b.mobile')
		->where($map)
		->order('count DESC')->group('a.u_id')->select();
	    return $this->fetch('index', ['list' => $list]);
	}
	
	
}
?>